/*
 * Project name:
     EasyPIC LCD HelloWorld
 * Author:
     Samuel.B.Atlan@gmail.com
 * Revision History:
     2010/05/09: initial release
 * Description:
     Simple "Hello World" program that uses the in build LCD displayer
 * Test configuration:
     MCU:             PIC16F887
     Dev.Board:       EasyPIC6
     Oscillator:      HS, 8.0000 MHz
     Ext. Modules:    -
     SW:              mikroC PRO for PIC 3.2
 * NOTES:
     - None
*/

char *text = "Hello World :-)";
// Port Expander module connections
  sbit  SPExpanderCS  at RA2_bit;
  sbit  SPExpanderRST at RA3_bit;
  sbit  SPExpanderCS_Direction  at TRISA2_bit;
  sbit  SPExpanderRST_Direction at TRISA3_bit;
// End Port Expander module connections

void init() {
  ANSEL  = 0b00000000;                      // Configure AN pins as digital
  ANSELH = 0b00000000;
  C1ON_bit = 0;                             // Disable comparators
  C2ON_bit = 0;

// Port Expander Library uses SPI1 module
  SPI1_Init();                              // Initialize SPI module used with PortExpander
  SPI_Lcd_Config(0);                        // Initialize Lcd over SPI interface
  SPI_Lcd_Cmd(_LCD_CLEAR);                  // Clear display
  SPI_Lcd_Cmd(_LCD_CURSOR_OFF);             // Turn cursor off
}

void main() {
  init();
  while(1) {
    SPI_Lcd_Cmd(_LCD_CLEAR);                  // Clear display
    SPI_Lcd_Out(1,1, text);                   // Print text to Lcd, row 1, column 1
    Delay_ms(200);
    SPI_Lcd_Cmd(_LCD_CLEAR);                  // Clear display
    SPI_Lcd_Out(2,1, "Youpi.");               // Alternate Print text to Lcd, row 2, column 1
    Delay_ms(200);
  }
}